package com.example.demo_mysql_mybatisplus.mybatisplus.daos;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo_mysql_mybatisplus.mybatisplus.entitys.User;
import com.example.demo_mysql_mybatisplus.util.grouped.GroupedPo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
//在对应的Mapper上继承基本的类baseMapper
public interface UserMapper extends BaseMapper<User> {
    //所有的CRUD已经编写完成
    //不需要像以前的配置一些xml

    @Insert("insert into user (name)values(#{user.name})")
    int insert2(@Param("user") User user);

    int insert3(@Param("user") User user);

    IPage<User> pageQuery(IPage iPage , User user );



    List<User> queryByQW4Demo(@Param("ew") QueryWrapper qw );
    List<User> queryByQW4Demo2(@Param("ew") QueryWrapper qw );
    Page<User> queryByQW4Demo3(@Param("page") IPage page , @Param("ew") QueryWrapper qw );



    List<User> getDataList(@Param("ew") QueryWrapper qw ,String groupField );
    List<GroupedPo> groupCounter(@Param("ew") QueryWrapper qw ,String groupField );
}
